package org.nokatag.Connection;

import java.sql.Connection;

import org.apache.ibatis.session.SqlSession;
import org.nokatag.system.BugInfoWrint;
import org.nokatag.system.IbatisUtil;
import org.nokatag.system.ServletNokaContext;

public class IbatisConnection implements DBConnectionInterface{

	public Connection getConnection() {
		SqlSession sqlSession = IbatisUtil.currentNewSession();
		ServletNokaContext.setIbatisSession(sqlSession);
		return sqlSession.getConnection();
	}

	public void closeConnection(Connection con) {
		try{
			if(null!=con){
				try{con.close();}catch(Exception se){BugInfoWrint.Print(se);}
				IbatisUtil.closeSession(ServletNokaContext.getIbatisSession());
			}
		}catch(Exception se){
			
		}
	}

}
